<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<base href="<PF:basePath/>" />
<title>高级检索-<PF:ParameterValue key="config.sys.title" /></title>
<meta name="description"
	content='<PF:ParameterValue key="config.sys.mate.description"/>'>
<meta name="keywords"
	content='<PF:ParameterValue key="config.sys.mate.keywords"/>'>
<meta name="author"
	content='<PF:ParameterValue key="config.sys.mate.author"/>'>
<meta name="robots" content="index,follow">
<jsp:include page="../atext/include-web.jsp"></jsp:include>
</head>
<body>
	<jsp:include page="../commons/head.jsp"></jsp:include>
	<jsp:include page="../commons/superContent.jsp"></jsp:include>
	<div class="containerbox">
		<div class="container ">
			<div style="margin-top: 20px;"></div>
			<div class="row column_box">
				<div class="col-lg-3"></div>
				<div class="col-lg-6">
					<div class="row">
						<div class="col-sm-12 column_box  hidden-xs">
							<img class=" center-block" src="<PF:basePath/>actionImg/PubHomelogo.do" alt="wcp"  style="max-width: 200px;"/>
						</div>
						<div class="col-sm-12 column_box">
							<div class="row">
								<div class="col-sm-12 ">
									<form action="websearchs/PubDo.do" id="websearchsPubDoFormId"
										method="post">
										<div class="input-group">
											<input type="hidden" name="indexTypes" id="indexTypesId"><input
												id="indexGroupsId" type="hidden" name="indexGroups">
											<input type="text" class="form-control" name="word"
												value="${word}" placeholder="请输入关键字..."> <span
												class="input-group-btn">
												<button class="btn btn-info" id="websearchsPubDoId"
													type="button"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
											</span>
										</div>
									</form>
									<script type="text/javascript">
										$(function() {
											$('#websearchsPubDoId,#websearchsPubDoFootId').bind('click',
												function() {
													var types,gourps;
													//拼接知识分类
													$("#groupidsbox :checked").each(function(i,obj){
														if(gourps){
															gourps=gourps+","+$(obj).attr('id');
														}else{
															gourps=$(obj).attr('id');
														}
													});
													//拼接知识小组
													$("#typeidsbox :checked").each(function(i,obj){
														if(types){
															types=types+","+$(obj).attr('id');
														}else{
															types=$(obj).attr('id');
														}
													});
													$('#indexTypesId').val(types);
													$('#indexGroupsId').val(gourps);
													$('#websearchsPubDoFormId').submit();
												});
											
										});
									</script>
								</div>
							</div>
						</div>
					</div>
					<div style="margin-top: 20px;"></div>
				</div>
				<div class="col-lg-3"></div>
			</div>
			<!-- /.row -->
			<div class="row">
				<div class="col-lg-3"></div>
				<div class="col-sm-6 " style="margin: auto;">
					<div class="row column_box">
						<div class="col-sm-12">
							<span class="column_title">选择分类，在分类下查询</span>
						</div>
					</div>
					<div class="panel panel-default  side_column">
						<div class="panel-body searchtypebox" id="typeidsbox">
							<div id="loadingDivId">加载分类中...</div>
							<ul class="doctypeUl">
								
							</ul>
						</div>
					</div>
					<div class="row column_box">
						<div class="col-sm-12">
							<span class="column_title"><button class="btn btn-info"
									id="websearchsPubDoFootId" type="button">检索</button></span>
						</div>
					</div>
					<hr />
				</div>
				<div class="col-lg-3"></div>
			</div>
		</div>
	</div>
	<jsp:include page="../commons/footServer.jsp"></jsp:include>
	<jsp:include page="../commons/foot.jsp"></jsp:include>
</body>
<script type="text/javascript">
var type_collapse_level=3;
var showQuestionNum=false;
</script>
<PF:IfParameterEquals key="config.sys.type.collapse.level" val="1">
<script type="text/javascript">
var type_collapse_level=1;
</script>
</PF:IfParameterEquals>
<PF:IfParameterEquals key="config.sys.type.collapse.level" val="2">
<script type="text/javascript">
var type_collapse_level=2;
</script>
</PF:IfParameterEquals>
<PF:IfParameterEquals key="config.sys.type.collapse.level" val="3">
<script type="text/javascript">
var type_collapse_level=3;
</script>
</PF:IfParameterEquals>
<script type="text/javascript">
	$(function() {
		$.post('webtype/PubLoadRType.html',{typeid:'${typeid}'}, function(flag) {
			var typeobj=$.parseJSON(flag);
			if(typeobj.types.length==0){
				$('#loadingDivId').html("<div class='alert alert-warning'>无分类信息<br/>请在后台添加分类!</div>");
			}
			//第一层 
			$(typeobj.types).each(function(i, obj1) {
				if (obj1.parentid == "NONE") {
					var html = new Array();
					html.push("<li>");
					html.push('<h5 class="showLableType">');
					html.push('<input type="checkbox" id="'+obj1.id+'" style="margin-right: 8px;">');
					html.push(obj1.name );
					if (obj1.num > 0) {
						html.push('<span style="color: #D9534F; font-weight: bold;">',obj1.num,showQuestionNum?"/":"",showQuestionNum?obj1.questionnum:"",'</span>');
					}
					if(type_collapse_level<=1){
						html.push('&nbsp;<a class="glyphicon glyphicon-chevron-down farm_tree_flag ',obj1.id,'"></a>');
					}
					html.push('</h5><ul>');
					//第二层
					$(typeobj.types).each(function(i, obj2) {
						if(obj2.parentid==obj1.id) {
							html.push("<li>");
							html.push('<h5 class="showLableType">');
							html.push('<input type="checkbox" id="'+obj2.id+'" style="margin-right: 8px;">');
							html.push(obj2.name);
							if (obj2.num > 0) {
								html.push('<span style="color: #D9534F; font-weight: bold;">',obj2.num,showQuestionNum?"/":"",showQuestionNum?obj2.questionnum:"",'</span>');
							}
							if(type_collapse_level<=2){
								html.push('<a class="glyphicon glyphicon-chevron-down farm_tree_flag ',obj2.id,'"></a>');
							}
							html.push('</h5><ul>');
							//第三层
							$(typeobj.types).each(function(i, obj3) {
								if(obj3.parentid==obj2.id) {
									html.push("<li>");
									html.push('<h5 class="showLableType">');
									html.push('<input type="checkbox" id="'+obj3.id+'" style="margin-right: 8px;">');
									html.push(obj3.name );
									if (obj3.num > 0) {
										html.push('<span style="color: #D9534F; font-weight: bold;">',obj3.num,showQuestionNum?"/":"",showQuestionNum?obj3.questionnum:"",'</span>');
									}
									if(type_collapse_level<=3){
										html.push('<a class="glyphicon glyphicon-chevron-down farm_tree_flag ',obj3.id,'"></a>');
									}
									html.push('</h5><ul>');
									//第四层
									$(typeobj.types).each(function(i, obj4) {
										if(obj4.parentid==obj3.id) {
											html.push("<li>");
											html.push('<h5 class="showLableType">');
											html.push('<input type="checkbox" id="'+obj4.id+'" style="margin-right: 8px;">');
											html.push(obj4.name );
											if (obj4.num > 0) {
												html.push('<span style="color: #D9534F; font-weight: bold;">',obj4.num,showQuestionNum?"/":"",showQuestionNum?obj4.questionnum:"",'</span>');
											}
											html.push('<a class="glyphicon glyphicon-chevron-down farm_tree_flag ',obj4.id,'"></a>');
											html.push('</h5>');
											html.push('<ul>');
											//第五层
											$(typeobj.types).each(function(i, obj5) {
												if(obj5.parentid==obj4.id) {
													html.push("<li>");
													html.push('<h5 class="showLableType">');
													html.push('<input type="checkbox" id="'+obj5.id+'" style="margin-right: 8px;">');
													html.push( obj5.name );
													if (obj5.num > 0) {
														html.push('<span style="color: #D9534F; font-weight: bold;">',obj5.num,showQuestionNum?"/":"",showQuestionNum?obj5.questionnum:"",'</span>');
													}
													html.push('<a class="glyphicon glyphicon-chevron-down farm_tree_flag ',obj5.id,'"></a>');
													html.push('</h5>');
													html.push("</li>");
												}
											});
											html.push('</ul>');
											html.push("</li>");
										}
									});
									html.push('</ul>');
									html.push("</li>");
								}
							});
							html.push('</ul>');
							html.push("</li>");
						}
					});
					html.push('</ul>');
					html.push("</li>");
					$('#loadingDivId').html("");
					$('.doctypeUl').append(html.join(""));
					//html.push('');
				}
			});
			//alert(typeobj.types.length);
			initTypesStyle();
			$(typeobj.typepath).each(function(i,obj){
				$('.'+obj.id).click();
			});
		});
	});
	function initTypesStyle(){
		$('a', '.showLableType').bind(
				'click',
				function() {
					if ($(this).attr('id')) {
						window.location = basePath + "webtype/view"
								+ $(this).attr('id') + "/Pub1.html";
					}
				});

		$('.farm_tree_flag').each(function(i, o) {
			if ($(this).parent().next().contents().length <= 1) {
				$(this).removeClass("farm_tree_flag");
				$(this).removeClass("glyphicon");
				$(this).removeClass("glyphicon-chevron-down");
			} else {
				$(this).parent().next().hide();
			}
		});
		$('.farm_tree_flag').bind('click', function() {
			var ul = $(this).parent().next();
			if ($(ul).is(':hidden')) {
				$(this).parent().next().show();
				$(this).removeClass("farm_tree_s");
				$(this).addClass("farm_tree_h");
				$(this).removeClass("glyphicon-chevron-down");
				$(this).addClass("glyphicon-chevron-up");
			} else {
				$(this).parent().next().hide();
				$(this).removeClass("farm_tree_h");
				$(this).addClass("farm_tree_s");
				$(this).removeClass("glyphicon-chevron-up");
				$(this).addClass("glyphicon-chevron-down");
			}
		});
		$(".searchtypebox input[type='checkbox']").bind('click', function() {
			if($(this).attr("checked")){
				//选中,上层li下面所有checkbox全部选中
				$(this).parent().parent().find('input').attr("checked", true);
			} else {
				$(this).parent().parent().find('input').attr("checked", false);
			}
		});
	}
</script>
</html>